package com.lw.jdbc;

import com.lw.jdbc.dao.UserDaoimpl;
import com.lw.jdbc.domain.User;

import java.sql.SQLException;
import java.util.Iterator;
import java.util.List;

public class App {
    public static void main(String[] args) throws SQLException {
        //创建UserDao对象
        UserDaoimpl userDaoimpl = new UserDaoimpl();  ////创建UserDaoimpl对象
        //delete
        userDaoimpl.delete(3);
        //add
        /*User user = new User();
        user.setUsername("刘伟");
        user.setPassword("123456");
        user.setAdress("胶州");
        userDaoimpl.add(user);*/
        //update
        /*User user = new User();
        user.setId(4);
        user.setUsername("李四");
        user.setPassword("123");
        user.setAdress("上海");
        userDaoimpl.update(user);*/
        //find
        List<User> list = userDaoimpl.find();
        Iterator<User> iterator = list.iterator();
        while (iterator.hasNext()){
            System.out.println(iterator.next());
        }
        //findById
        /*User user = userDaoimpl.findById(4);
        System.out.println(user);*/
    }
}

